package com.xs.bookspoststation.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class DBHelperStudent extends SQLiteOpenHelper {

    private static final String DATA_NAME = "student.db";
    private static final int VERSION = 1;

    /**
     * name: 想要建立数据库的名字
     * factory:null
     * version:版本1
     */
    public DBHelperStudent(Context context, String name, SQLiteDatabase.CursorFactory factory,int version){
        super(context,DATA_NAME,null,VERSION);
    }

    /**
     * 程序运行建立数据库，只运行一次
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        //sno 学号 sname 姓名 spwd密码 sex 性别 sphone 电话 sclass 班级 spro 专业 sde 系部
        String sql = "create table studentInfo(_id integer primary key autoincrement," +
                "sno varchar(10),sname varchar(20),spwd varchar(10), " +
                "sex varchar(20),sphone varchar(20),sclass varchar(20),spro varchar(10), " +
                "sde varchar(20))";
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
